﻿<?php
if (!isset($_SESSION["taikhoan"]))
	{
		header("Location: dbcl-dangnhap.php");
	}
	include "connect.php"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<script language="javascript">
	function emptyCheck()
	{
		if (document.f2.nd.value != "")
			document.f2.cn.disabled = false;
		else document.f2.cn.disabled = true;
	}
</script>

<table width="700" align="center">
	<tr > 
	   <td height="40" align="right"><a href="dbcl-capnhat.php?nav=themtieuchi" class="style4"><img src="image/them.png" />&nbsp; Thêm Tiêu Chí Mới</a>       </td>
	</tr>

	<tr>
		<td>
		<!--chứa bảng tìm kiếm tieu chi -->
			<table width="700" align="center" border="0" style="border:1px solid #0066FF" cellspacing="0">
						
					  <tr> 
							<td height="25" colspan="3" align="center" bordercolor="#FFFFFF" background="image/bg_header.gif">
								<span class="style2">Chọn Tiêu Chí Cập nhật</span></td>
					  </tr>
						
						<tr bordercolor="#FFFFFF"> 
						  <td colspan="3" height="50" align="center" style="font-size:18px">
						  
								  <form name="f1" method="post">
										  
											Khoa :    &nbsp;&nbsp;			
											<select name="tieuchi">
											    <?php
												        $sql = mysql_query("select a.ma_tc, a.noidung_tc
																			from `tieu chi` a, `tieuchi hocki` b
																			where a.ma_tc = b.ma_tc
																			and da_xoa = 0
																			and b.ma_hknk = (select max(ma_hknk) from `hocki nienkhoa`)"); 
														while($r = mysql_fetch_array($sql))
														{
														      $matc = $r[0];
															  $nd = $r[1];
												?>
															  <option><?php echo " $matc"; ?></option>
												<?php 
														}
												?>
												 <option value="" selected="selected"> - Chọn Tiêu Chí</option>
											</select> &nbsp;&nbsp;
											  
										   <input name="tk" type="submit"  id="tk" value="   Tìm Kiếm  " />
								  </form>
						 </td>
					  </tr>
					  
					
			</table>
		</td>
	</tr>
</table>

<table>
     <tr>
	     <td height="30"></td>
	 </tr>
</table>

<?php
if (isset($_POST["tieuchi"]))
{
     $matc = $_POST["tieuchi"];
	 if ($matc != "")
	 {
			        $sql_query = mysql_query("select * from `tieu chi` where ma_tc = '$matc' ");
	
				    $r = mysql_fetch_row($sql_query);
					$nd = $r[1];
}					
				
?>
									 <form name="f2" method="post" action="" onsubmit="">
							  <table width="500" align="center" border="0" style="border:1px solid #0066FF" cellspacing="0">
									
								  <tr> 
										<td height="30" colspan="2" align="center" bordercolor="#FFFFFF" background="image/bg_header.gif">
											<span style="font-size:24px; color:#FFFFFF; font-weight:bold;">Thông tin Tiêu Chí</span></td>
								  </tr>
								  
								  <tr><td height="15" colspan="2" bordercolor="#FFFFFF"></td></tr>
									
								  <tr bordercolor="#FFFFFF" align="center"> 
									  <td  height="30" style="font-size:18px" width="200">Mã Tiêu Chí:</td>
									  <td align="left"><input type="text" name="matc" value="<?php echo $matc; ?>"  class="mau" readonly="" size="4" /></td>
								  </tr>
								  
								  <tr bordercolor="#FFFFFF" align="center"> 
									  <td  height="30" style="font-size:18px">Nội Dung:</td>
									 <td align="left"><textarea name="nd" cols="30" rows="5" onkeyup="emptyCheck();"><?php echo $nd; ?></textarea></td>
								  </tr>
								  <tr><td height="15" colspan="2" bordercolor="#FFFFFF"></td></tr>
								  
								  <tr bordercolor="#FFFFFF">
									  <td  align="right" height="30">
										  <input type="submit" value="Cập nhật" name="cn" disabled="true" />
										  <input type="button" value="Xóa" name="xoa" onclick="location.href = 'dbcl_xoatieuchi.php?matc=<?php echo $matc; ?>';" />
									</td>
									  <td align="center"><input type="reset" value="Làm Lại" name="huy" onclick="document.f2.cn.disabled = true" /></td>
								 </tr>
								 <tr><td colspan="2" height="20">&nbsp;</td></tr>
								
						</table>
				  </form>	
				  
				<?php 
}
				?>  
				
<table>
     <tr>
	     <td height="30"></td>
	 </tr>
</table>	
<?php 
                if(isset($_POST["cn"]))
				{
				          $matc=$_POST["matc"];
				          $noidung=$_POST["nd"];
						  $sql=mysql_query("select max(ma_hknk) from `hocki nienkhoa`");
						  $s=mysql_fetch_row($sql);
						  $hknk=$s[0];
						  $kq=mysql_query(" update `tieu chi` set noidung_tc='$noidung' where ma_tc='$matc' ");
						  $kq1=mysql_query(" update `tieuchi hocki` set ma_hknk='$hknk' where ma_tc='$matc' ");
						  echo"<script type='text/javascript'>alert('Cap Nhat Thanh Cong')</script>";
		                  echo'<meta http-equiv="refresh" content="0;URL=dbcl-capnhat.php?nav=cntc">';
						  
				}
?>

</body>
</html>
